<template>
  <div class="denglu">
    <div class="header">注册页面</div>
    <div class="ip">
      <input class="loginn" type="text" placeholder="请输入邮箱" v-model="emile" ><br>
      <input class="login" type="text"  placeholder="用户名/电话" v-model="inputlogin"/><br />
      <input class="pass" type="password" placeholder="密码" v-model="inputpass"/>
      <input class="passs"  type="password" placeholder="请确认密码" v-model="inputpasss"/>
    </div>
    <button class="b" :disabled=!is_checked @click="btn()">登录</button>
    <div class="dixia"><span @click="phone()">手机号登录</span><span>忘记密码</span></div>
 <div class="xy">
    <input type="checkbox" v-model="is_checked">
     <div class="xieyi">
         <span class="yuedu">已阅读并同意</span>
         《用户服务协议》丶《隐私政策》
     </div>
    </div>
 
  </div>

</template>

<script>
import { user_register} from "../../../api/index";
export default {
  data() {
    return {
      emile:"",
      inputlogin: "",
      inputpass: "",
      inputpasss:"",
      is_checked:false 

      
    };
  },

  methods: {
    phone(){
          this.$router.push("/denglu")
    },

    btn() {
      if(this.emile&&this.inputlogin&&this.inputpass&&this.inputpasss){
        if(/^1[3-9]\d{9}$/.test(this.inputlogin)&&this.inputpass==this.inputpasss){
        user_register({ phone: this.inputlogin, pass: this.inputpass }).then(
        (res) => {
          console.log(res.data);
            this.$router.push("/denglu")
        }
       );
        }else if(/^1[3-9]\d{9}$/.test(this.inputlogin)==false){
          alert('手机号格式不正确')
        }else{
          alert('两次密码不一致')
        }
      }else{
        alert('注册信息不完整')
      }
      
    },

  },
};
</script>

<style>
.header {
  width: 100%;
  height: 40px;
  margin-top: 100px;
  font-size: 25px;
}
.ip {
  margin-top: 40px;
}
.loginn,
.passs,
.login, 
.pass{
  width: 100%;
  height: 60px;
  border-top: 0px;
  border-left: 0px;
  border-right: 0px;
  border-bottom:2px solid #e5e5e5 ;
  outline: none;
}
.b {
  width: 100%;
  height: 50px;
  line-height: 50px;
  color: #999999;
  background: #e0e0e0;
  text-align: center;
  border-radius: 30px;
  margin:20px 0;
  border: none;
  
}
.dixia {
  display: flex;
  justify-content: space-between;
  color: #4ca9ea;
}
.xy{
    display: flex;
    margin-top: 50px;
}
.yuedu{
    width: 16px;
    height: 16px;
    border-radius:50% ;
}
.xieyi{
    color: #4ca9ea;
    margin-left: 20px;
}
.xieyi span{
    color: #999999;
}
</style>